package com.zero.rabbitmq.pubsub;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.zero.rabbitmq.utils.ConnectionUtil;
import com.zero.rabbitmq.utils.RabbitConstant;

import java.util.Scanner;

/**
 * 天气发布者
 * exchange : Fanout模式
 */

public class WeatherBureau {

    public static void main(String[] args) throws Exception {

        String input = new Scanner(System.in).next();

        Connection connection = ConnectionUtil.getConnection();

        Channel channel = connection.createChannel();

        /**
         * Params:
         * exchange – the exchange to publish the message to
         * routingKey – the routing key
         * props – other properties for the message - routing headers etc
         * body – the message body
         */
        channel.basicPublish(RabbitConstant.EXCHANGE_WEATHER,"",null,input.getBytes());

        channel.close();
        connection.close();
    }

}
